﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace SmartSpace.Vote.Parts
{
    public partial class VoteThemeList : SmartSpace.Web.SsPart
    {
        public VoteThemeList()
            : base(new Guid("{D5CC6180-0A3C-409D-A657-5FF6B5896EC0}"))
        {

        }

        protected override void OnLoad(object sender, EventArgs e)
        {
            this.RegisterCss("site", "../Resources/Style/site.css");
            this.RegisterJs("common", "../Resources/JavaScript/common.js");

            if (!IsPostBack)
            {
                bind();
            }
        }

        public void bind()
        {
            VoteServices services = new VoteServices();
            vote_rep1.DataSource = services.GetAllThemes();
            vote_rep1.DataBind();
        }

        protected void vote_rep1_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            string id = e.CommandArgument.ToString();
            Guid gid = new Guid(id);
            if (e.CommandName == "Delete")
            {
                VoteServices services = new VoteServices();
                services.DeleteVoteTheme(gid);
            }
        }
    }
}